package com.newhero.product.module.sys.service.impl;

import com.newhero.product.common.mybatis.mapper.EntityWrapper;
import com.newhero.product.common.mybatis.mapper.Wrapper;
import com.newhero.product.common.mybatis.plugins.Page;
import com.newhero.product.common.service.impl.BaseServiceImpl;
import com.newhero.product.module.sys.mapper.AttachmentMapper;
import com.newhero.product.module.sys.model.Attachment;
import com.newhero.product.module.sys.service.IAttachmentService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AttachmentServiceImpl extends BaseServiceImpl<AttachmentMapper, Attachment> implements IAttachmentService {
	@Override
	public void selectAttachmentsBySourceId(Page<Attachment> p, String sourceId) {
		if(sourceId!=null){
			EntityWrapper<Attachment> entityWrapper = new EntityWrapper<Attachment>();
			entityWrapper.eq("SOURCEID", sourceId);
			entityWrapper.orderBy("ATTACHMENTORDER");
			p = this.selectPage(p, entityWrapper);
		}
	}

	@Override
	public List<Attachment> selectAttachmentsBySourceId(String sourceId) {
		if (sourceId != null) {
			Wrapper<Attachment> wrapper = new EntityWrapper<Attachment>();
			wrapper.eq("SOURCEID", sourceId);
			wrapper.orderBy("ATTACHMENTORDER");
			return this.selectList(wrapper);
		}
		return null;
	}
}
